home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#18 (Mar 87)
/
Basic Graf3D
/
CLR Circle Demo
next >
Wrap
Text File
|
1987-02-09
|
2KB
|
71 lines
' 2D Circle Demo
' ©MacTutor March 1987
' By Dave Kelly
' CLR Graph3DLib version
' Requires CLR Graph3DLib
' Set your own volume names
LIBRARY "XP™ 40-6:Software Dev:MS Basic:CLR Graph3D:Graph3DLib"
LIBRARY "XP™ 40-6:Software Dev:MS Basic:CLR Graph3D:ToolBox"
initialize:
WINDOW 1,"",(122,22)-(424,324),3
OpenPort3D 'Set 3D output to window 1
' Next initialize variables to be used in library calls.
x1!=0:x2!=0:y1!=0:y2!=0
s!=0:t!=0:u!=0:v!=0
xAngle!=0:yAngle!=0:zAngle!=0:Angle!=0
SetRect viewrect1%(1),2,2,300,300 'set the viewport rectangle
' convert single precision to fixed point values
Fs2Fix 0!,x1!
Fs2Fix 0!,y1!
Fs2Fix 1!,x2!
Fs2Fix 1!,y2!
Fs2Fix 0!,xAngle!
Fs2Fix 0!,yAngle!
Fs2Fix 0!,zAngle!
Fs2Fix 25!,Angle!
viewport viewrect1%(1)
' frame rect. so we can see it.
FRAMERECT (VARPTR(viewrect1%(1)))
LookAt x1!,y1!,x2!,y2!
ViewAngle Angle!
roll zAngle!
yaw yAngle!
Pitch xAngle!
MainRoutine:
DIM x!(360),y!(360)
pi!=3.141593
DEF FNrad(deg)=pi!*deg/180
LOCATE 2,2:TEXTSIZE 9:INPUT "Enter step value: <18> ";Stp
IF Stp=0 THEN Stp=18
CLS
PENMODE(8)
LOCATE 2,2: PRINT"Step =";Stp
FOR n=1 TO 360
Angle=FNrad(n)
x!(n)=(SIN(Angle)+1)/2
y!(n)=(COS(Angle)+1)/2
NEXT n
FOR n=1 TO 360 STEP Stp
m=n+1
WHILE m<>n
Fs2Fix x!(n),s
Fs2Fix y!(n),t
Fs2Fix x!(m),u
Fs2Fix y!(m),v
MoveTo2D s,t
lineTo2d u,v
m=m+Stp
IF m>360 THEN m=1
WEND
NEXT n
LOCATE 25,2:PRINT "Press any key";
key$=""
WHILE key$=""
key$=INKEY$
WEND
WINDOW CLOSE 1
END